#include <stdio.h> 
int main()

{
	char str[50];
	int i,j,score[5],sum;
	gets(str);
	i=0;
	j=0;
    while(str[i])
	{
    	while(str[i]==' ')i++;
    	if(str[i]>='1'&&str[i]<='9'&&(str[i+1]==' '||str[i+1]=='\0')) score[j++]=str[i]-'0';
    	else if(str[i]=='1'&&str[i+1]=='0'&&(str[i+2]==' '||str[i+2]=='\0'))score[j++]=10;
    	else if((str[i]=='J'||str[i]=='j'||str[i]=='Q'||str[i]=='q'||str[i]=='K'||str[i]=='k')&&(str[i+1]==' '||str[i+1]=='\0'))score[j++]=10;
    	else return 0;
    	i++;
    	if(j>=3)break;
    }
    sum=0;
    for(j=0;j<3;j++) 
	{
        if(score[j]==1)score[j]=11;
        sum+=score[j];
    }
    if(sum>21)
	{
        sum=0;
        for(j=0;j<3;j++) 
		{
        if(score[j]==11)score[j]=1;
        sum+=score[j];
        }
    }
    printf("%d\n",sum);
    return 0;

}
